package com.stu.covid.business.service;

import com.stu.covid.business.entity.vo.ReportEchartVO;
import com.stu.covid.business.mapper.StudentHealthMapper;
import com.stu.covid.business.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Service
public class ReportService {

    @Autowired
    private StudentHealthMapper studentHealthMapper;

    public ReportEchartVO reportEchart() {
        ReportEchartVO reportEchartVO = new ReportEchartVO();
        List<String> dataList = DateUtils.getWeekEveryDayString();
        List<String> valueList = new ArrayList<>();
        for (String day : dataList) {
            valueList.add(studentHealthMapper.selectHealthAvg(day));
        }
        reportEchartVO.setDayList(dataList);
        reportEchartVO.setValueList(valueList);
        return reportEchartVO;
    }
}
